package org.brisling.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class StringUtil {
	
	
	public StringUtil(){};
	
	public static HashMap<String,Object> splitRequestStr2Map(String inData){
		
		String splitChar = "&";
		HashMap<String,Object> retMap = new HashMap<String,Object>();
		
		if(inData!=null){
			if(splitChar!=null){
				String[] _list = inData.split(splitChar); 
				
				if(_list!=null&&_list.length>0){
					for(int i =0;i<_list.length;i++){
						String[] _nameValue = _list[i].split("=");
						if(_nameValue!=null&&_nameValue.length>1){
							retMap.put(_nameValue[0], _nameValue[1]);
						}
					}
				}
			}
		}
		return retMap;
	}
	
	public static List<Long> splitStr2Long(String inStr,String splitStr){
		
		List<Long> retList = new ArrayList<Long>();
		
		if(inStr!=null){
			if(splitStr!=null){
				String[] _s = inStr.split(splitStr);
				if(_s!=null&&_s.length>0){
					for(int i=0;i<_s.length;i++){
						retList.add(LongUtil.getLongValue(_s[i], null));
					}
				}
			}
		}
		
		return retList;
		
	}
	
	

}
